home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14305 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  94 lines

  1. Path: rover.ucs.ualberta.ca!news
  2. From: ryangall@gpu.srv.ualberta.ca (Ryan Gallagher)
  3. Newsgroups: comp.lang.c++,ualberta.cmput.201
  4. Subject: class/function pointer help!
  5. Date: 29 Mar 1996 21:44:39 GMT
  6. Organization: University of Alberta, Edmonton, Canada
  7. Message-ID: <4jhlk7$1eke@pulp.ucs.ualberta.ca>
  8. NNTP-Posting-Host: async1-11.remote.ualberta.ca
  9. Mime-Version: 1.0
  10. X-Newsreader: WinVN 0.99.2
  11.  
  12. Hi, I have a class that uses a function pointer. The problem Im having is 
  13. that the pointer doesnt want to access the function when the function is a 
  14. local function to the calling class. Here is what I mean....
  15.  
  16. class expression
  17.        {
  18.         public:
  19.  
  20.                 string S;
  21.         list L;
  22.         .
  23.         .
  24.         int   initlist();
  25.         .
  26.         int   isexpr(int);
  27.        };
  28.  
  29.  
  30. list, and string are both classes.
  31.  
  32. char * string::POP( int (* separator)(int c) )
  33. {
  34.  
  35.  int n=0,m=0,r,size=strlen(S);
  36.  char *A,*B,*C;
  37.  
  38.   A=new char[size+1]; // allocate space for strings A & B
  39.    .
  40.    .
  41.    
  42.    
  43.     //  find the first occurence of a separator character
  44.     while(!(*separator)(A[n]) && A[n]) n++;
  45.  
  46.     .
  47.     .
  48.     .
  49.   return A;
  50. }
  51.  
  52. // heres the calling function
  53.  
  54. int expression::initlist(void)
  55. {
  56.  char *temp;
  57.  float F;
  58.  char C;
  59.  
  60.   L.init();
  61.  
  62.   while((temp=S.POP( ::isexpr )))
  63.   {
  64.     F=C=0;
  65.     assert(convert(F,C,temp));
  66.     L.Add(L.Assign(F,C));     
  67.     delete[] temp;
  68.   }
  69.  
  70.  return 0;
  71. }
  72.  
  73.  
  74. this works when I define isexpr(int) globally, but I want to beable to 
  75. call function expression::isexpr(int).....when I do this...
  76.  
  77.   while((temp=S.POP( isexpr )))
  78.   {
  79.  
  80.  the compiler say:" member function must be called or its address taken."
  81.  
  82. how do I declare the member function as a function pointer?!
  83.  
  84.  
  85.  
  86.  
  87. thanks
  88. ------
  89. Please mail me back if possible.
  90.  
  91.   
  92.  
  93.  
  94.